<!DOCTYPE html>
<html >
	<head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0, width=device-width"/>
        <meta name="format-detection" content="telephone=no"/>
        <title>工单详情</title>
        <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
        <link rel="stylesheet" type="text/css" href="../../css/api.css" />
        <link rel="stylesheet" type="text/css" href="../../css/list-format.css"/>
        <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
				<style>
				.aui-content-wxx{
					width: 100%;
					margin: 0;
				}
				.aui-content-wxx ul{
					background-color: #fff;
					border-radius: 0;
					overflow: hidden;
					margin-bottom: 10px;
					padding: 0 3%;
				}
				</style>
	</head>
	<body style="width: 100%">
		<script id="billDetail-template" type="text/x-dot-template">
			<ul class="aui-list-view">
			<div class="darktitle" ><h2><img class="tit_img" src="../../image/bt_icon2.png" alt=""/>出入站申请单信息</h2></div>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请编码</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.applyid != null ? it.applyid:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 工单状态</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.processflag}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请人</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.createoper_name != null ? it.createoper_name:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请部门</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.createunit_name != null ? it.createunit_name:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.createtime != null ? it.createtime:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请上站时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.applystanddate != null ? it.applystanddate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请站离站时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.applyoffsitedate != null ? it.applyoffsitedate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请上站原因</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.cause != null ? it.cause:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 进站人单位</div>
			<div class="aui-col-xs-7 aui-pull-right">
            {{? it.company == '1001' }}
            移动
            {{?? it.company == '1002' }}
            联通
            {{?? it.company == '1003' }}
            电信
            {{?? it.company == '1004' }}
            铁塔

            {{?? it.faulttype == 'OTHER' }}
            其它
            {{?}}
			</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 站点归属运营商</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.st_operators != null ? it.st_operators:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 联系人</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.contact_person != null ? it.contact_person:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 联系电话</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.contact_phone != null ? it.contact_phone:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 申请是否需要随工</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.applyisneedperson == 'Y' ? '是':'否'}}</div>
			</li>

			<!-- <li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 审核是否通过</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.auditFlag != null ? it.auditFlag:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 处理描述</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.auditMero != null ? it.auditMero:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 上站原因</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.standCause != null ? it.standCause:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 上站方式</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.standType != null ? it.standType:''}}</div>
			</li>-->
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 备注</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.remark != null ? it.remark:''}}</div>
			</li>
			</ul>
			{{?it.isneedperson != null}}
			<ul class="aui-list-view">
			<div class="darktitle" ><h2><img class="tit_img" src="../../image/bt_icon2.png" alt=""/>协调上站信息</h2></div>

			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 是否需要随工</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isneedperson == 'Y'?'是':'否'}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 是否如约</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isbooking == 'Y'?'是':'否'}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 协调上站时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.coorstanddate != null?it.coorstanddate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 协调离站时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.cooroffsitedate != null?it.cooroffsitedate:''}}</div>
			</li>
			</ul>
			{{?}}
			{{?it.signuserid_name != null}}
			<ul class="aui-list-view">
			<div class="darktitle" ><h2><img class="tit_img" src="../../image/bt_icon2.png" alt=""/>签到信息</h2></div>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 签到人</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.signuserid_name != null?it.signuserid_name:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 签到时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.signdate != null?it.signdate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 签到经度</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.signlon != null?it.signlon:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 签到维度</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.signlat != null?it.signlat:''}}</div>
			</li>
			</ul>
			{{?}}
			{{? it.revertdate != null}}
			<ul class="aui-list-view">
			<div class="darktitle" ><h2><img class="tit_img" src="../../image/bt_icon2.png" alt=""/>回单信息</h2></div>

			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 回单人</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.revertuserid_name != null?it.revertuserid_name:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 回单时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.revertdate != null?it.revertdate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 是否免责</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isreief == 'Y' ? '是':'否'}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 免责条款</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isreieftype != null?it.isreieftype:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 免责具体原因</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isreiefcause != null?it.isreiefcause:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 上站完成时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.finishstanddate != null?it.finishstanddate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 运营商上站目标是否达成</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isfinishstand == 'Y' ? '是':'否'}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 上站事宜讲述</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.standmero != null?it.standmero:''}}</div>
			</li>
			</ul>
			{{?}}
			{{? it.isstand != null}}
			<ul class="aui-list-view">
			<div class="darktitle" ><h2><img class="tit_img" src="../../image/bt_icon2.png" alt=""/>是否及时上站信息</h2></div>

			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 是否及时上站</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isstand == 'Y' ? '是':'否'}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 实际上站时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.standdate != null?it.standdate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 是否及时上站原因</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isstandcause != null?it.isstandcause:''}}</div>
			</li>
			</ul>
			{{?}}
			{{? it.agreeuserid != null}}
			<ul class="aui-list-view">
			<div class="darktitle" ><h2><img class="tit_img" src="../../image/bt_icon2.png" alt=""/>是否同意信息</h2></div>

			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 区域经理</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.agreeuserid != null?it.agreeuserid:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 操作时间</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.agreeoperdate != null?it.agreeoperdate:''}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 是否同意</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.isagree == 'Y' ? '是':'否'}}</div>
			</li>
			<li class="aui-list-view-cell border_b" >
			<div class="aui-col-xs-4 aui-pull-left red">• 意见</div>
			<div class="aui-col-xs-7 aui-pull-right">{{=it.agreemero != null?it.agreemero:''}}</div>
			</li>
			</ul>
			{{?}}
		</script>
		<div class="aui-content aui-content-wxx" id="standBillDetail">

		</div>
	</body>
	<script type="text/javascript" src="../../script/jquery-1.11.3.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/doT.min.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/debug.js"></script>
	<script type="text/javascript" src="../../script/config.js"></script>
	<script type="text/javascript" src="../../script/client.api.js"></script>
	<script type="text/javascript" src="../../script/aui-alert.js"></script>
	<script>
		var opts = {};
		apiready = function() {

			var applyId = api.pageParam.applyId;
			var isHistory = api.pageParam.isHistory;
			if (applyId != null && applyId != '' && applyId != 'undefined') {
				opts.applyid = applyId;
				opts.stationname=api.pageParam.stationName;
			}

			if (isHistory != null && isHistory != '' && isHistory != 'undefined') {
				opts.ishistory = isHistory;
			}
			api.showProgress({
				title : '加载中',
				modal : false
			});
			$client.getStandBillDetail(opts, function(ret, err) {
				//取值到远程开门页面
					if(ret.model.company == "1001"){
						company="移动";
					}else if(ret.model.company == "1002"){
						company="联通";
					}else if(ret.model.company == "1003"){
						company="电信";
					}else if(ret.model.company == "1004"){
						company="铁塔";
					}else{
						company="其他";
					}
					$api.setStorage('st_code', ret.model.st_code); //站址编码
					$api.setStorage('UserUnit', company); //用户单位
					$api.setStorage('UserName', ret.model.contact_person); //用户姓名
					$api.setStorage('UserMobile', ret.model.contact_phone); //用户手机
					$api.setStorage('OpenReason', ret.model.cause); //开门原因
				if (ret) {
					if (ret.success) {
						console.log(getObj(ret.model));
						var parolData={};
						parolData.stationname=ret.model.st_name;
						parolData.stationcode=ret.model.st_code;
						parolData.deviceid=ret.model.st_deviceid;
						$api.setStorage('parolData', parolData);
						getAreaman(ret,ret.model);
					} else {
						api.toast({
							msg : ret.data_info,
							location : 'middle'
						});
					}
				} else {
					api.toast({
						msg : err.msg,
						location : 'middle'
					});
				}
				api.hideProgress();
			});
		};

		function initView(ret,billModel){
		renderTemp('standBillDetail', 'billDetail-template', billModel);
						$api.setStorage("standBillModel", billModel);
						//将处理流程存入缓存
						$api.setStorage("standBillAction", ret.actionList);

						var userid = $api.getStorage('user') ? $api.getStorage('user').userid : null;
						/*如果当前的用户id等于建单人id（createoper） 才可以进行（是否及时上站和最终确认操作），否则隐藏操作按钮 */
						if (billModel.processflag_dictvalue == 'ISPROMPT' || billModel.processflag_dictvalue == 'SENISPROMPT') {
							if (userid && billModel.createoper != userid) {
								showlog('该出入站工单[' + billModel.applyid + ']建单人(' + billModel.createoper + ')非当前用户(' + userid + ')，无法操作工单！');
								api.toast({
									msg : '该出入站工单建单人非当前用户，无法操作工单！'
								});
								api.execScript({
									name : 'mainStandBillDetail',
									script : 'cb_toggleMenu(false)'
								});
							}
						}
						//“是否同意”的出入站工单需有区域经理处理
						if (billModel.processflag_dictvalue == 'ISAGREE') {
							if (userid && billModel.st_areamanager.indexOf(userid) == -1) {
								showlog('该出入站工单[' + billModel.applyid + ']区域经理(' + billModel.st_areamanager + ')非当前用户(' + userid + ')，无法操作工单！');
								api.toast({
									msg : '该出入站工单区域经理非当前用户，无法操作工单！'
								});
								api.execScript({
									name : 'mainStandBillDetail',
									script : 'cb_toggleMenu(false)'
								});
							}
						}
		}

		//获取区域经理
		function getAreaman(ret,billModel) {
			var userNameList = new Array;
			var userIdList = new Array;
			$client.getAreaManagers({
				siteid : billModel.st_id
			}, function(ret1, err) {
				if (ret1) {
					if (ret1.success) {
						var areaManagers = ret1.list;
						for (var i = 0, size = areaManagers.length; i < size; i++) {
							//						$('<option>').text(areaManagers[i].username).val(areaManagers[i].userid).appendTo('#areaManagerId');
							userNameList.push(areaManagers[i].username);
							userIdList.push(areaManagers[i].userid);
						}
//						var userInfoId = listToStr(userIdList);
//											alert(userInfoId);
						billModel.st_areamanager = listToStr(userIdList);
						billModel.st_areamanager_name = listToStr(userNameList);
						initView(ret,billModel);
//						var content = $api.byId('stationDetail');
//						var tpl = $api.byId('stationDetail-template').text;
//						var tempFn = doT.template(tpl);
//						content.innerHTML = tempFn(billModel);
//						$api.setStorage('stationModel', billModel);
//						$api.setStorage('stationName', billModel.st_name);
						api.parseTapmode();
					} else {
						initView(ret,billModel);
						api.parseTapmode();
					}
				} else {
					initView(ret,billModel);
					api.parseTapmode();
				}
			});
		}

		//把list转为字符串
		function listToStr(stringList) {
			if (stringList == null) {
				return null;
			}
			var result = "";
			var flag = false;
			for (var i = 0; i < stringList.length; i++) {
				var string = stringList[i];
				if (flag) {
					//	                result.append(",");
					result += ",";
				} else {
					flag = true;
				}
				result += string;
			}
			return result.toString();
		}

		 function cb_openBillPicDetail() {
//          pageParam.billId = api.pageParam.billId;
//          pageParam.billSn = api.pageParam.billSn;
            api.openFrame({
                name : 'standPicDetail_frm',
                url : 'standPicDetail_frm.html',
                bounces : false,
                pageParam : opts
            });
        }



	</script>
</html>
